<extend name="Public/base"/>

<block name="body">

	<div class="main-title">
		<h2>口碑商户</h2>
	</div>

    <div class="cf">
        <div class="fl">
            <a class="btn" href="{:U('kbxx')}">商户信息</a>

        </div>
        <php>
            $LOAN_STATUS = C('LOAN_STATUS');
        </php>
        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">

                <input name="title" class="search-input" value="" placeholder="user_id、姓名" type="text">
                <a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search"></i></a>

            </div>

        </div>
    </div>

	<div class="data-table table-striped" >

		<table style="font-size:14px;">
			<thead>
				<tr>
                    <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
					
					<th>用户UID</th>
                    <th>商户姓名</th>
                    <th>码主姓名</th>
                    <th>码主支付宝</th>
                    <th>user_id</th>
                    <th >回扣费率</th>
                    <th>收款范围</th>
                    <th>授权时间</th>
                    <th>授权到期时间</th>
                    <th>使用状态</th>
                    <th>授权状态</th>
                    <th>下架原因</th>
                    <th>暂缓金额</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<notempty name="_list">
				<volist name="_list" id="rows">
					<tr>
                        <td><input class="ids" type="checkbox" name="id[]" value="{$rows['id']}" /></td>
                        
						<td>{$rows['uid']}</td>
                        <td><php>
                            $one=D('Kbxx')->where(['uid'=>$rows['uid']])->find();
                            echo $one['name'];
                        </php></td>
                        <td>{$rows.name}</td>
                        <td>{$rows.alipay}</td>
                        <td>
                            {$rows['user_id']}   
                            <input type="hidden" style="height:30px;" class="text input-large app_auth_code" readonly="readonly" name="app_auth_code" value="{$rows['app_auth_code']}">


                        </td>
                        <td>{$rows['rate']}</td>
                        <td >
                            <php>
                                if($rows['type']==1){
                                    echo '<input type="text" class="type" style="background:none;border:none;width:65px;" value="1-500">';
                                }else if($rows['type']==2){
                                    echo '<input type="text" class="type" style="background:none;border:none;width:65px;" value="501-800">';
                                }else if($rows['type']==3){
                                    echo '<input type="text" class="type" style="background:none;border:none;width:65px;" value="801-2000">';
                                }else if($rows['type']==4){
                                    echo '<input type="text" class="type" style="background:none;border:none;width:65px;" value=">2000">';
                                }
                            </php>

                        </td>
                        <td>
                            <php>
                                if(empty($rows['create_time'])){
                                echo '';
                            }else{
                                echo date("Y-m-d",$rows['create_time']);
                            }
                            </php>
                        </td>
                        <td>
                            <php>
                                if(empty($rows['expires_in'])){
                                echo '';
                            }else{
                            $time=$rows['expires_in']+$rows['create_time'];
                                echo date("Y-m-d",$time);
                            }
                            </php>
                        </td>
                        <td>
                            <php>
                                if($rows['use_status']==1){
                                    echo '<button class="xj" style="background:#fff">已上架</button>';
                                }else{
                                    echo '<button class="sj" style="background:#fff;color:red">已下架</button>';
                                }
                            </php>
                        </td>

             
                        <td>
                            <php>
                                if($rows['status']==0){
                                    echo '<font style="color:red">待审核</font>';
                                }else{
                                    echo '已授权';
                                }
                            </php>
                        </td>
                        <td>
                                <php>
                                if($rows['use_status']==1){
                                    echo '';
                                }else{
                                    echo $rows['cause'];
                                }
                            </php>
                        </td>

                        <td>
                                <php>
                                if($rows['use_status']==1){
                                    echo '';
                                }else{
                                    echo $rows['money'];
                                }
                            </php>
                        </td>
                        
						<td>

                            &nbsp;&nbsp;
							<a title="详细" href="{:U('view?id='.$rows['id'])}">详细</a>
						</td>
					</tr>
				</volist>
				<else/>
				<td colspan="14" class="text-center"> aOh! 暂时还没有内容! </td>
				</notempty>
			</tbody>
		</table>



	</div>
    <p style="color:red">修改收款范围请修改成1-500,501-800,801-2000,>2000。</p>
    <div class="page"  style="float:left;margin-right:300px;">{$_page}</div>
</block>

<block name="script">
    <link href="/Public/static/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <link href="/Public/static/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/Public/static/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="/Public/static/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
    $(function(){
        //搜索功能
        $("#search").click(function(){
            var url = $(this).attr('url');
            var status = $("#sch-sort-txt").attr("data");
            var type   = $("#sch-sort-txt_type").attr("data");
            var query  = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
            query = query.replace(/^&/g,'');
            if(status != ''){
                query += '&status=' + status + "&" + query;
            }
            if(type != ''){
                query += '&type=' + type + "&" + query;
            }
            if( url.indexOf('?')>0 ){
                url += '&' + query;
            }else{
                url += '?' + query;
            }
            window.location.href = url;
        });

        Think.setValue("extend", {$info.extend|default=0});
            //导航高亮
            highlight_subnav('{:U('index')}');

                //回车搜索
    $(".search-input").keyup(function(e){
        if(e.keyCode === 13){
            $("#search").click();
            return false;
        }
    });





        /* 状态搜索子菜单 */
        $(".search-form").find(".drop-down1").hover(function(){
            $("#sub-sch-menu").removeClass("hidden");
        },function(){
            $("#sub-sch-menu").addClass("hidden");
        });
        $("#sub-sch-menu li").find("a").each(function(){
            $(this).click(function(){
                var text = $(this).text();
                $("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
                $("#sub-sch-menu").addClass("hidden");
            })
        });

        $(".search-form").find(".drop-down_type").hover(function(){
            $("#sub-sch-menu_type").removeClass("hidden");
        },function(){
            $("#sub-sch-menu_type").addClass("hidden");
        });

        $("#sub-sch-menu_type li").find("a").each(function(){
            $(this).click(function(){
                var text = $(this).text();
                $("#sch-sort-txt_type").text(text).attr("data",$(this).attr("value"));
                $("#sub-sch-menu_type").addClass("hidden");
            })
        });
        $('#time-start').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
            minView:2,
            autoclose:true
        });

        $('#time-end').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
            minView:2,
            autoclose:true
        });




       $('.sj').click(function(){
            
            var app_auth_code=$(this).parent().parent().find('.app_auth_code').val();
            // alert(app_auth_code)
            $.ajax({
                type:'post',
                data:{'app_auth_code':app_auth_code,'type':2},
                url:"{:U('shouquan')}",
                success:function(m){
                    // alert(m)
                    if(m==1){
                        alert('操作成功！');
                        location.reload();
                    }else if(m==0){
                        alert('操作失败！');
                    }else{
                        alert(m)
                    }
                }
            })

        })
        $('.xj').click(function(){
            
            var app_auth_code=$(this).parent().parent().find('.app_auth_code').val();
            // alert(app_auth_code)
            $.ajax({
                type:'post',
                data:{'app_auth_code':app_auth_code,'type':3},
                url:"{:U('shouquan')}",
                success:function(m){
                    // alert(m)
                    if(m==1){
                        alert('操作成功！');
                       location.reload();
                    }else if(m==0){
                        alert('操作失败！');
                    }else{
                        alert(m)
                    }
                }
            })

        })

        $('.type').focus(function(){
            $(this).attr('style','background:none;border:1px solid #ccc;width:65px;')
        })

        $('.type').blur(function(){
            $(this).attr('style','background:none;border:none;width:65px;')
        })


        $('.type').change(function(){
            var app_auth_code=$(this).parent().parent().find('.app_auth_code').val();
            var val=$(this).val();
            var _type='';
            if(val=='1-500'){
                _type=1;
            }else if(val=='501-800'){
                _type=2;
            }else if(val=='801-2000'){
                _type=3;
            }else if(val=='>2000'){
                _type=4;
            }else{
                alert('请输入正确范围')
            }

            if(_type===''){

            }else{
                $.ajax({
                    type:'post',
                    data:{'app_auth_code':app_auth_code,'_type':_type},
                    url:"{:U('shouquan')}",
                    success:function(m){
                        // alert(m)
                        if(m==1){
                            alert('操作成功！');
                           location.reload();
                        }else if(m==0){
                            alert('操作失败！');
                        }else{
                            alert(m)
                        }
                    }
                })
            }
            

        })













    })


</script>
</block>